package com.gy.smartmanagement.process.processdevice.fragment;

import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gy.smartmanagement.R;
import com.gy.smartmanagement.base.fragment.BaseFragment;
import com.gy.smartmanagement.process.processdevice.ProcessDeviceActivity;
import com.gy.smartmanagement.process.processdevice.adapter.ProfileAdapter;
import com.gy.smartmanagement.process.processdevice.adapter.ProfileFarmAdapter;
import com.gy.smartmanagement.process.processdevice.mvp.DevicePresenter;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class ProfileFragment extends BaseFragment {

  @BindView(R.id.farm_rv)
  RecyclerView farm_rv;
  @BindView(R.id.position_ll)
  LinearLayout position_ll;
  @BindView(R.id.farm_detail_tv)
  TextView farm_detail_tv;
  @BindView(R.id.farm_detail_ll)
  LinearLayout farm_detail_ll;
  @BindView(R.id.device_id_tv)
  TextView device_id_tv;
  @BindView(R.id.device_name_tv)
  TextView device_name_tv;
  @BindView(R.id.device_type_tv)
  TextView device_type_tv;
  @BindView(R.id.device_department_tv)
  TextView device_department_tv;
  @BindView(R.id.device_address_tv)
  TextView device_address_tv;
  @BindView(R.id.device_time_tv)
  TextView device_time_tv;
  @BindView(R.id.camera_tv)
  TextView camera_tv;
  @BindView(R.id.device_iv)
  ImageView device_iv;
  @BindView(R.id.profile_rv)
  RecyclerView profile_rv;

  public static final String TAG = "ProfileFragment";
  private ProcessDeviceActivity processDeviceActivity;
  private DevicePresenter devicePresenter;
  private ProfileFarmAdapter profileFarmAdapter;

  @Override
  public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof ProcessDeviceActivity) {
      processDeviceActivity = (ProcessDeviceActivity) context;
    }
  }

  public static ProfileFragment newInstance() {

    Bundle args = new Bundle();

    ProfileFragment fragment = new ProfileFragment();
    fragment.setArguments(args);
    return fragment;
  }

  @Override
  public int getLayoutResId() {
    return R.layout.fragment_profile;
  }

  @Override
  public void onUnBind() {

  }

  @Override
  public void initialization() {
    devicePresenter = processDeviceActivity.getdevicePresenter();
    List<String> dataList = new ArrayList<>();
    for (int i = 0; i < 7; i++) {
      dataList.add(i + "车间");
    }
    profileFarmAdapter = new ProfileFarmAdapter(dataList, getContext());

    farm_rv.setLayoutManager(new GridLayoutManager(getContext(), 4));
    farm_rv.setAdapter(profileFarmAdapter);

    ProfileAdapter profileAdapter=new ProfileAdapter(getContext(),dataList);

    profile_rv.setLayoutManager(new GridLayoutManager(getContext(),4));
    profile_rv.setAdapter(profileAdapter);
  }


}
